#region BLL VERSION  2.6
/* Kho_HangHoa
 *
 * Author: LANNT    
 * Copyright: (c) - LANNT 
 * Created:   23/09/2012 5:30:56 PM
 * Last modify: 2012-08-01 11:15 PM 
 * Note   :   Changes to this file may cause incorrect behavior and will be lost if
*            the code is regenerated.
*/
#endregion

#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using GQ.Utils;

using Chili.Opf3;
using Chili.Opf3.Relations;
using Chili.Opf3.DynamicProperties;
#endregion

namespace GQ.BLL.QuanLyKho
{
	#region Kho_HangHoa
	[Serializable]
	[Persistent("KHO_HANGHOA", PoolSize = 10)]
	public partial class Kho_HangHoa 
	{
		#region Members
		private Guid _id=Guid.NewGuid();
		private Guid? _loaihanghoaid=null;
		private string _ma=null;
		private string _ten=null;
		private string _barcode=null;
		private string _thoihanbaohanh=null;
		private string _donvitinh=null;
		private string _donvichuyendoi=null;
		private decimal? _tylechuyendoi=null;
		private Guid? _khoid=null;
		private string _taikhoanchiphi=null;
		private string _taikhoandoanhthu=null;
		private decimal? _thuesuat=null;
		private string _xuatxu=null;
		private decimal? _dongiamua=null;
		private decimal? _dongiaban=null;
		private decimal? _dongiaban1=null;
		private decimal? _dongiaban2=null;
		private string _ghichu=null;
		private Guid? _nhacungcapid=null;
		private bool? _iscongcudungcu=null;
		private Guid? _companyid=null;
		private int? _nhomhangid=null;
		#endregion
		
		#region Public Properties
		
		[Field("ID", Identifier=true, AllowDBNull=false)]
		public Guid ID
		{
			get{ return _id; }
			set{ _id = value; }
		}
		
		/// <summary>
		/// Loai hang hoa. CategoryID.
		/// </summary>
		[Field("LOAIHANGHOAID")]
		public Guid? LoaiHangHoaID
		{
			get{ return _loaihanghoaid; }
			set{ _loaihanghoaid = value; }
		}
		
		[Field("MA")]
		public string Ma
		{
			get{ return _ma; }
			set{ _ma = value; }
		}
		
		[Field("TEN")]
		public string Ten
		{
			get{ return _ten; }
			set{ _ten = value; }
		}
		
		[Field("BARCODE")]
		public string BarCode
		{
			get{ return _barcode; }
			set{ _barcode = value; }
		}
		
		[Field("THOIHANBAOHANH")]
		public string ThoiHanBaoHanh
		{
			get{ return _thoihanbaohanh; }
			set{ _thoihanbaohanh = value; }
		}
		
		[Field("DONVITINH")]
		public string DonViTinh
		{
			get{ return _donvitinh; }
			set{ _donvitinh = value; }
		}
		
		[Field("DONVICHUYENDOI")]
		public string DonViChuyenDoi
		{
			get{ return _donvichuyendoi; }
			set{ _donvichuyendoi = value; }
		}
		
		[Field("TYLECHUYENDOI")]
		public decimal? TyLeChuyenDoi
		{
			get{ return _tylechuyendoi; }
			set{ _tylechuyendoi = value; }
		}
		
		[Field("KHOID")]
		public Guid? KhoID
		{
			get{ return _khoid; }
			set{ _khoid = value; }
		}
		
		[Field("TAIKHOANCHIPHI")]
		public string TaiKhoanChiPhi
		{
			get{ return _taikhoanchiphi; }
			set{ _taikhoanchiphi = value; }
		}
		
		[Field("TAIKHOANDOANHTHU")]
		public string TaiKhoanDoanhThu
		{
			get{ return _taikhoandoanhthu; }
			set{ _taikhoandoanhthu = value; }
		}
		
		[Field("THUESUAT")]
		public decimal? ThueSuat
		{
			get{ return _thuesuat; }
			set{ _thuesuat = value; }
		}
		
		[Field("XUATXU")]
		public string XuatXu
		{
			get{ return _xuatxu; }
			set{ _xuatxu = value; }
		}
		
		[Field("DONGIAMUA")]
		public decimal? DonGiaMua
		{
			get{ return _dongiamua; }
			set{ _dongiamua = value; }
		}
		
		[Field("DONGIABAN")]
		public decimal? DonGiaBan
		{
			get{ return _dongiaban; }
			set{ _dongiaban = value; }
		}
		
		[Field("DONGIABAN1")]
		public decimal? DonGiaBan1
		{
			get{ return _dongiaban1; }
			set{ _dongiaban1 = value; }
		}
		
		[Field("DONGIABAN2")]
		public decimal? DonGiaBan2
		{
			get{ return _dongiaban2; }
			set{ _dongiaban2 = value; }
		}
		
		[Field("GHICHU")]
		public string GhiChu
		{
			get{ return _ghichu; }
			set{ _ghichu = value; }
		}
		
		[Field("NHACUNGCAPID")]
		public Guid? NhaCungCapID
		{
			get{ return _nhacungcapid; }
			set{ _nhacungcapid = value; }
		}
		
		[Field("ISCONGCUDUNGCU")]
		public bool? IsCongCuDungCu
		{
			get{ return _iscongcudungcu; }
			set{ _iscongcudungcu = value; }
		}
		
		[Field("COMPANYID")]
		public Guid? CompanyID
		{
			get{ return _companyid; }
			set{ _companyid = value; }
		}
		
		/// <summary>
		/// Hang hoa thuoc nhom nao. CategoryID.
		/// </summary>
		[Field("NHOMHANGID")]
		public int? NhomHangID
		{
			get{ return _nhomhangid; }
			set{ _nhomhangid = value; }
		}
		
		#endregion
		#region Methods Install
		public Kho_HangHoa LoadByID()
		{
		   return DbContext.ObjectContext.GetObject<Kho_HangHoa>("ID={0}",ID);
		}
		public static Kho_HangHoa LoadByID(Guid id)
		{
		   return DbContext.ObjectContext.GetObject<Kho_HangHoa>("ID={0}",id);
		}
		public void DeleteByID(Guid id)
		{
		   ID=id;
		   Chili.Opf3.ObjectInfo  objInfo= GQ.Utils.DbContext.ObjectContext.GetObjectInfo(this);
			  objInfo.ObjectState = Chili.Opf3.ObjectStates.Loaded;
			  objInfo.MarkForDeletion = true;
		   DbContext.ObjectContext.PersistChanges<Kho_HangHoa>(this);
		}
		public Kho_HangHoa LoadBy(string conditions, params object[] parameter)
		{
		   return DbContext.ObjectContext.GetObject<Kho_HangHoa>(conditions, parameter);
		}
		public void Save()
		{
		   DbContext.ObjectContext.PersistChanges<Kho_HangHoa>(this);
		}
		public void Delete()
		{
			 DbContext.ObjectContext.MarkForDeletion(this);
		   DbContext.ObjectContext.PersistChanges<Kho_HangHoa>(this);
		}
		#endregion Methods Install
		#region Methods Collection
		public static IList<Kho_HangHoa> LoadAll()
		{
		   return DbContext.ObjectContext.GetObjectSet<Kho_HangHoa>();
		}
		public static IList<Kho_HangHoa> LoadAll(string sortby)
		{
		   return DbContext.ObjectContext.GetObjectSet<Kho_HangHoa>("Sortby " + sortby);
		}
		public static IList<Kho_HangHoa> LoadAllBy(string conditions, params object[] parameter)
		{
		   return DbContext.ObjectContext.GetObjectSet<Kho_HangHoa>(conditions, parameter);
		}
		public static IList<Kho_HangHoa> LoadAllBy(Chili.Opf3.Query.SqlQuery query)
		{
		   return DbContext.ObjectContext.GetObjectSet<Kho_HangHoa>(query);
		}
		public static void SaveAll(IList<Kho_HangHoa> collection)
		{
		   foreach (Kho_HangHoa item in collection)
		   {
		       item.Save();
		   }
		}
		public static void DeleteAll(IList<Kho_HangHoa> collection)
		{
			foreach (Kho_HangHoa item in collection)
			{
		 		item.Delete();
			}
		}
		#endregion Methods Collection

	}
	#endregion
	
}
